package fishBids.group3.behaviour.auctioneer;

import fishBids.group3.AgAuctioneer;
import fishBids.group3.common.Constants;
import fishBids.group3.utils.Utils;
import jade.core.behaviours.SimpleBehaviour;
import jade.lang.acl.ACLMessage;

public class AuctioneerAuctionOverBehaviour extends SimpleBehaviour {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7373673590070014202L;
	
	public AuctioneerAuctionOverBehaviour(AgAuctioneer auctioneerAg){
		this.auctioneerAg = auctioneerAg;
	}

	@Override
	public void action() {
			//Send  AuctionOver message to the bidders
				Utils.sendMessageWithConceptAgentsCollection(ACLMessage.INFORM, 
																		this.auctioneerAg.getCodec(), 
																		this.auctioneerAg.getOntology(), 
																		this.auctioneerAg.getBiddersRegistered(), 
																		Constants.AUCTION_OVER, 
																		this.auctioneerAg, 
																		null);
				//Send AuctionOver message to the bank
				Utils.sendMessage(ACLMessage.INFORM, this.auctioneerAg.getCodec(), this.auctioneerAg.getOntology(), this.auctioneerAg.getBankID(), Constants.AUCTION_OVER, this.auctioneerAg);
				System.out.println("auctioneer3: the auction is over");
				finished = true;	
			
	}
	

	@Override
	public boolean done() {
		return finished;
	}
	
	AgAuctioneer auctioneerAg;
	boolean finished = false;
}
